#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>

#define SOCKFILE_PATH   "/tmp/my_sock_file"

int main()
{
	int server;
	struct sockaddr_un server_addr;
	char buf[100];
	
	// 1. create the socket
	server = socket(AF_UNIX, SOCK_STREAM, 0);
	if(server == -1){
		perror("socket failed");
		exit(-1);
	}
	// 2. connect
	server_addr.sun_family = AF_UNIX;
	strncpy(server_addr.sun_path, SOCKFILE_PATH, sizeof(SOCKFILE_PATH));

	if(connect(server, (struct sockaddr *)&server_addr, sizeof(server_addr)) == -1){
		perror("connet failed");
		exit(-1);
	}

	// 3. read msg
	read(server, buf, 100);
	printf("get msg : %s\n", buf);

	// 4. close
	close(server);

	return 0;
	
}